package sjtu.edu.cn.se.compiler11.gui.errorview;
import java.text.SimpleDateFormat;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import sjtu.edu.cn.se.compiler11.gui.variabletable.*;


public class TableLabelProvider extends LabelProvider  implements ITableLabelProvider {
		
	public String getColumnText(Object element, int columnIndex)
	{
			String result = null;
			
			if (element instanceof ErrorInfo){
				ErrorInfo e = (ErrorInfo)element;
				switch (columnIndex){
					case 0: result = e.getDes().toString(); break;
					case 1:	result = e.getRes().toString();break;
					case 2:	result = "line " + String.valueOf(e.getLoc());break;
					case 3: result = e.getType().toString();break;
				}
			}
			
			if (element instanceof VariableTableInfo){
				VariableTableInfo e = (VariableTableInfo)element;
				switch (columnIndex){
					case 0: result = e.getType(); break;
					case 1:	result = e.getName();break;
					case 2:	result = String.valueOf(e.getLineNumber());break;
				}
			}
			
			return result;
				
	}
	
		public Image getColumnImage(Object element, int columnIndex) {		
			return null;
		}
	}